<?php


namespace App\Util;


use App\Model\SysErrLog;
use App\Model\TaskCrontabLog;
use EasySwoole\EasySwoole\Crontab\AbstractCronTask;
use EasySwoole\EasySwoole\Task\TaskManager;

class SystemErr
{
    public static function write( \Throwable $e, ?string $index = ''){
      $msg =  "Err{$index}: {$e->getMessage()} at {$e->getLine()} in {$e->getFile()}";
      TaskManager::getInstance()->async(function () use ($msg){
            SysErrLog::create(['msg' => $msg])->save();
      });
    }
}